//验证数据库中的用户和密码和手机是否存在
const User = {

  //查询用户名|手机号
  queryUserName(option){
    return "select * from user where name = '"+option.userName+"' or phone = '"+option.userName+"' "
  },

  //查询用户名|手机号===》密码
  queryUserPwd(option){
    return "select * from user where (name = '"+option.userName+"' or phone = '"+option.userName+"') and password = '"+option.userPwd+"' "
  },

  //增加一条用户记录
  insertData(option){
    let userName = option.userName
    //引入插件
    let jwt = require('jsonwebtoken')
    //用户信息
    let payload = {name:userName}
    //口令
    let secret = 'vueBeats'
    let token = jwt.sign(payload,secret)
    return "insert into user (name,phone,password,nickname,imgUrl,token) values ('','"+option.userName+"', '123456', '"+option.userName+"', './img/img.png' ,'"+token+"')"
  }
}
module.exports = User;